package com.formation.tocea.library.client.ui.form;

import com.formation.tocea.library.client.listener.HideFormListener;
import com.formation.tocea.library.client.listener.LoginSubmitListener;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PasswordTextBox;
import com.google.gwt.user.client.ui.TextBox;

public class LoginForm extends Grid {
	private Label loginLabel;
	private Label passwordLabel;
	private TextBox loginTextBox;
	private PasswordTextBox passwordTextBox;
	private HorizontalPanel buttonPanel;
	private Button submitButton;
	private Button closeButton;
	
	public LoginForm() {
		init();
	}

	public void init() {
		setWidth("100");
		resize(3, 2);
		
		loginLabel = new Label("Login");
		passwordLabel = new Label("Mot de passe");
		
		loginTextBox = new TextBox();
		passwordTextBox = new PasswordTextBox();
		submitButton = new Button("OK");
		closeButton = new Button("Fermer");
		
		buttonPanel = new HorizontalPanel();
		buttonPanel.setSpacing(3);
		buttonPanel.add(submitButton);
		buttonPanel.add(closeButton);
		
		submitButton.addClickHandler(new LoginSubmitListener(this));
		closeButton.addClickHandler(new HideFormListener(this));
		
		setWidget(0, 0, loginLabel);
		setWidget(0, 1, loginTextBox);
		setWidget(1, 0, passwordLabel);
		setWidget(1, 1, passwordTextBox);
		setWidget(2, 1, buttonPanel);
	}

	public Label getLoginLabel() {
		return loginLabel;
	}

	public Label getPasswordLabel() {
		return passwordLabel;
	}

	public TextBox getLoginTextBox() {
		return loginTextBox;
	}

	public PasswordTextBox getPasswordTextBox() {
		return passwordTextBox;
	}

	public Button getSubmitButton() {
		return submitButton;
	}

	public Button getCloseButton() {
		return closeButton;
	}
}
